﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows8Accelerator.Core.Xaml.Html;

namespace Windows8Accelerator.Core.Xaml.Controls.RichText
{
    public class LineBreakingFormatVisitor : ControlVisitor
    {
        public LineBreakingFormatVisitor(SuperHtmlNode superHtmlNode, SuperHtmlNodeVisitor parentVisitor)
            : base(superHtmlNode, parentVisitor)
        {
            VisitChildren = true;
        }

        protected override void InternalVisitNode1(SuperHtmlNode htmlNode)
        {
            State.RequiresLineBreaking = true;
            switch (htmlNode.TagName)
            {
                case "div":
                    break;
                case "p":
                    State.RequiresDoubleLineBreaking = true;
                    break;
                case "h1":
                    TextFormat.Merge(State.H1TextFormat);
                    break;
                case "h2":
                    TextFormat.Merge(State.H2TextFormat);
                    break;
                case "h3":
                    TextFormat.Merge(State.H3TextFormat);
                    break;
                case "h4":
                    TextFormat.Merge(State.H4TextFormat);
                    break;
                case "h5":
                    TextFormat.Merge(State.H5TextFormat);
                    break;
                case "h6":
                    TextFormat.Merge(State.H6TextFormat);
                    break;
            }
        }

        protected override void InternalPosVisitNode1(SuperHtmlNode htmlNode)
        {
            State.RequiresLineBreaking = true;
        }
    }
}
